<html>
<head>
<title>searchPage.ets</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
.s0 { color: #a9b7c6;}
.s1 { color: #faa23d;}
.s2 { color: #aa7dfc;}
.s3 { color: #bbb529;}
.s4 { color: #e2da90;}
.s5 { color: #db7e9b;}
.s6 { color: #b3e54c;}
</style>
</head>
<body bgcolor="#2b2b2b">
<table CELLSPACING=0 CELLPADDING=5 COLS=1 WIDTH="100%" BGCOLOR="#606060" >
<tr><td><center>
<font face="Arial, Helvetica" color="#000000">
searchPage.ets</font>
</center></td></tr></table>
<pre><span class="s0">import </span><span class="s1">{ </span><span class="s0">http </span><span class="s1">} </span><span class="s0">from </span><span class="s2">'@kit.NetworkKit'</span>
<span class="s0">import </span><span class="s1">{ </span><span class="s0">BusinessError </span><span class="s1">} </span><span class="s0">from </span><span class="s2">'@kit.BasicServicesKit'</span>
<span class="s0">import </span><span class="s1">{ </span><span class="s0">Users </span><span class="s1">} </span><span class="s0">from </span><span class="s2">'./pageOne'</span>


<span class="s3">@</span><span class="s0">Entry</span>
<span class="s3">@</span><span class="s0">Component</span>
<span class="s0">struct searchPage</span><span class="s1">{</span>
  <span class="s3">@</span><span class="s0">Consume</span>
  <span class="s0">stackPath</span><span class="s4">:</span><span class="s0">NavPathStack</span>
  <span class="s3">@</span><span class="s0">State message</span><span class="s4">:</span><span class="s0">string</span><span class="s4">=</span><span class="s2">&quot;&quot;</span>
  <span class="s3">@</span><span class="s0">State arr</span><span class="s4">:</span><span class="s0">Users</span><span class="s4">=</span><span class="s0">new Users</span><span class="s5">()</span>

  <span class="s0">build</span><span class="s5">() </span><span class="s1">{</span>
    <span class="s0">NavDestination</span><span class="s5">() </span><span class="s1">{</span>
      <span class="s0">Column</span><span class="s5">(</span><span class="s1">{</span><span class="s0">space</span><span class="s4">:</span><span class="s6">15</span><span class="s1">}</span><span class="s5">) </span><span class="s1">{</span>
        <span class="s0">Row</span><span class="s5">(</span><span class="s1">{ </span><span class="s0">space</span><span class="s4">: </span><span class="s6">15 </span><span class="s1">}</span><span class="s5">) </span><span class="s1">{</span>
          <span class="s0">Stack</span><span class="s5">() </span><span class="s1">{</span>
            <span class="s0">TextInput</span><span class="s5">(</span><span class="s1">{ </span><span class="s0">placeholder</span><span class="s4">: </span><span class="s2">&quot;搜索联系人、群聊或聊天记录&quot;</span><span class="s4">, </span><span class="s0">text</span><span class="s4">: </span><span class="s0">this</span><span class="s4">.</span><span class="s0">message </span><span class="s1">}</span><span class="s5">)</span>
              <span class="s4">.</span><span class="s0">onChange</span><span class="s5">(</span><span class="s0">value </span><span class="s4">=&gt; </span><span class="s0">this</span><span class="s4">.</span><span class="s0">message </span><span class="s4">= </span><span class="s0">value</span><span class="s5">)</span>
              <span class="s4">.</span><span class="s0">width</span><span class="s5">(</span><span class="s2">&quot;85%&quot;</span><span class="s5">)</span>
            <span class="s0">Image</span><span class="s5">(</span><span class="s0">$r</span><span class="s5">(</span><span class="s2">&quot;app.media.search&quot;</span><span class="s5">))</span><span class="s4">.</span><span class="s0">width</span><span class="s5">(</span><span class="s6">20</span><span class="s5">)</span><span class="s4">.</span><span class="s0">margin</span><span class="s5">(</span><span class="s1">{ </span><span class="s0">left</span><span class="s4">: </span><span class="s2">&quot;75%&quot; </span><span class="s1">}</span><span class="s5">)</span><span class="s4">.</span><span class="s0">onClick</span><span class="s5">(() </span><span class="s4">=&gt; </span><span class="s1">{</span>
              <span class="s0">let httpRequest </span><span class="s4">= </span><span class="s0">http</span><span class="s4">.</span><span class="s0">createHttp</span><span class="s5">()</span><span class="s4">;</span>
              <span class="s0">httpRequest</span><span class="s4">.</span><span class="s0">request</span><span class="s5">(</span><span class="s2">&quot;http://192.168.143.7:8080/DouYin/search?userName=&quot; </span><span class="s4">+ </span><span class="s0">this</span><span class="s4">.</span><span class="s0">message </span><span class="s4">+ </span><span class="s2">&quot;&quot;</span><span class="s4">,</span>
                <span class="s5">(</span><span class="s0">err</span><span class="s4">: </span><span class="s0">BusinessError</span><span class="s4">, </span><span class="s0">data</span><span class="s4">: </span><span class="s0">http</span><span class="s4">.</span><span class="s0">HttpResponse</span><span class="s5">) </span><span class="s4">=&gt; </span><span class="s1">{</span>
                  <span class="s0">this</span><span class="s4">.</span><span class="s0">arr </span><span class="s4">= </span><span class="s0">JSON</span><span class="s4">.</span><span class="s0">parse</span><span class="s5">(</span><span class="s0">data</span><span class="s4">.</span><span class="s0">result</span><span class="s4">.</span><span class="s0">toString</span><span class="s5">()) </span><span class="s0">as Users</span>
                <span class="s1">}</span><span class="s5">)</span>
            <span class="s1">}</span><span class="s5">)</span>
          <span class="s1">}</span>

          <span class="s0">Text</span><span class="s5">(</span><span class="s2">&quot;取消&quot;</span><span class="s5">)</span><span class="s4">.</span><span class="s0">onClick</span><span class="s5">(() </span><span class="s4">=&gt; </span><span class="s1">{</span>
            <span class="s0">this</span><span class="s4">.</span><span class="s0">stackPath</span><span class="s4">.</span><span class="s0">pop</span><span class="s5">()</span>
          <span class="s1">}</span><span class="s5">)</span>
        <span class="s1">}</span><span class="s4">.</span><span class="s0">width</span><span class="s5">(</span><span class="s2">&quot;100%&quot;</span><span class="s5">)</span><span class="s4">.</span><span class="s0">margin</span><span class="s5">(</span><span class="s1">{ </span><span class="s0">top</span><span class="s4">: </span><span class="s6">15</span><span class="s4">, </span><span class="s0">left</span><span class="s4">: </span><span class="s6">15 </span><span class="s1">}</span><span class="s5">)</span>

        <span class="s0">Row</span><span class="s5">(</span><span class="s1">{ </span><span class="s0">space</span><span class="s4">: </span><span class="s6">15 </span><span class="s1">}</span><span class="s5">) </span><span class="s1">{</span>
          <span class="s0">Image</span><span class="s5">(</span><span class="s0">$rawfile</span><span class="s5">(</span><span class="s0">this</span><span class="s4">.</span><span class="s0">arr</span><span class="s4">.</span><span class="s0">userImg</span><span class="s5">))</span><span class="s4">.</span><span class="s0">width</span><span class="s5">(</span><span class="s6">50</span><span class="s5">)</span><span class="s4">.</span><span class="s0">borderRadius</span><span class="s5">(</span><span class="s6">40</span><span class="s5">)</span>
          <span class="s0">Text</span><span class="s5">(</span><span class="s0">this</span><span class="s4">.</span><span class="s0">arr</span><span class="s4">.</span><span class="s0">userName</span><span class="s5">)</span>
        <span class="s1">}</span><span class="s4">.</span><span class="s0">width</span><span class="s5">(</span><span class="s2">&quot;95%&quot;</span><span class="s5">)</span><span class="s4">.</span><span class="s0">onClick</span><span class="s5">(() </span><span class="s4">=&gt; </span><span class="s1">{</span>
          <span class="s0">this</span><span class="s4">.</span><span class="s0">stackPath</span><span class="s4">.</span><span class="s0">pushPathByName</span><span class="s5">(</span><span class="s2">'pageOne'</span><span class="s4">,</span><span class="s0">this</span><span class="s4">.</span><span class="s0">arr</span><span class="s4">.</span><span class="s0">userId as number</span><span class="s5">)</span><span class="s4">;</span>
        <span class="s1">}</span><span class="s5">)</span>

      <span class="s1">}</span>
    <span class="s1">}</span><span class="s4">.</span><span class="s0">hideTitleBar</span><span class="s5">(</span><span class="s0">true</span><span class="s5">)</span>
  <span class="s1">}</span>
<span class="s1">}</span>
<span class="s3">@</span><span class="s0">Builder</span>
<span class="s0">function buildsearch</span><span class="s5">()</span><span class="s1">{</span>
  <span class="s0">searchPage</span><span class="s5">()</span>
<span class="s1">}</span></pre>
</body>
</html>